import request from "@/utils/request";
import { base } from "@/const/baseUrl";
// const base = "http://www.whxgjt.com:9527";

// 分享
export const getJsTicket = (url) => {
    return request.get(`${base}/business/activity/getSignature`, {
        params: {
            url
        }
    })
}

// code 换 openid
export const getOenIdByCode = (code) => {
    return request.get(`${base}/business/activity/getOenIdByCode`, {
        params: {
            code
        }
    })
}

// 抽奖
export const lottery = (data) => {
    return request.get(`${base}/business/activity/lottery`, {
        params: {
            userId: data.userId,    // 用户微信openId
            lotteryType: data.lotteryType   // 抽奖类型 1答题 2 分享
        }
    })
}

// 中奖记录
export const lotteryRecord = (userId) => {
    return request.get(`${base}/business/activity/lotteryRecord`, {
        params: {
            userId
        }
    })
}

// 查询用户的收货地址
export const getUserAddress = (userId) => {
    return request.get(`${base}/business/activity/userAddress`, {
        params: {
            userId
        }
    })
}

// 新加/修改用户的收件地址
export const saveAddress = (data) => {
    return request.post(`${base}/business/activity/saveAddress`, data)
}

// 查询当前用户的留言
export const getUserMessage = (userId) => {
    return request.get(`${base}/business/activity/message/user/list`, {
        params: {
            userId
        }
    })
}

// 添加留言
export const addMessage = (data) => {
    return request.get(`${base}/business/activity/message/add`, {
        params: {
            userId: data.userId,
            message: data.message
        }
    })
}

// 删除留言
export const deleteMessage = (data) => {
    return request.get(`${base}/business/activity/message/delete`, {
        params: {
            messageId: data.messageId,
            userId: data.userId
        }
    })
}

// 查询所有的留言
export const getAllMessage = () => {
    return request.get(`${base}/business/activity/message/all`);
}

// 获取是否已经完成首次分享 true 已完成过 false 未完成
export const getIsFinishFirstShare = (userId) => {
    return request.get(`${base}/business/activity/message/getIsFinishFirstShare`, {
        params: {
            userId
        }
    })
}